﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using LX.NHibernate.Service;
using LX.NHibernate.Service.Implement;
using LX.NHibernate.Utils;

namespace NHibernate.Main.Controllers
{
    public class UserController : Controller
    {
        //private IUser_InfoManage userInfoService = new User_InfoManage();

        private IUser_InfoManage userInfoService;
        public UserController(User_InfoManage userService)
        {
            userInfoService = userService;
        }

        //
        // GET: /User/
        public ActionResult Index()
        {
            LX.NHibernate.Data.Domain.User_Info model = userInfoService.GetUser_Info(1017);

            return View(model);
        }
        public ActionResult getList(int pageIndex = 1)
        {
            //List<LX.NHibernate.Data.Domain.User_Info> modelUser_InfoList = userInfoService.GetUser_InfoList();
            int pageSize = 2;
            int Total = 0;
            IList<LX.NHibernate.Data.Domain.User_Info> modelUser_InfoList = userInfoService.GetUser_InfoListForPage(x => x.User_ID > 1010, x => x.Create_Date, pageIndex, pageSize, out  Total);

            ViewBag.pageIndex = pageIndex;
            ViewBag.pageSize = pageSize;
            ViewBag.PageCount = Convert.ToInt32(Math.Ceiling((double)Total / pageSize));
            ViewBag.Total = Total;

            return View(modelUser_InfoList);
        }

        public ActionResult TestLog()
        {
            //int a = 10;
            //int b = 0;
            //var result = a / b;

            LogHelper.Error("记录日志打印");

            return View();
        }
    }
}
